<template>
	<view class="content">
		<!--单据 -->
		<purchbillsTow ref="purchBillListBox" @setBillsThree="setBillsThree" ></purchbillsTow>
		<purchBillsThree ref="purchBillsInfo" @addNewCustom="addNewCustom" @changeYunBillPrice="changeYunBillPrice"></purchBillsThree>
	</view>
</template>

<script>
		
	import purchbillsTow from '../../components/purchaseBills/PurchbillsTow.vue';
	import purchBillsThree from '../../components/purchaseBills/PurchBillsThree.vue';
	
	import staticConst from '../../js/const/StaticConst.js';
	
	import eventCtrl from "../../js/event/EventCtrl.js";
	
	import supplierCtrl from "../../js/supplier/SupplierCtrl.js";
	
	export default {
		components: { 
				purchbillsTow , purchBillsThree},
		data() {
			return {
				curPage:staticConst.CG_DJ,
				tab:-1,
			}
		},
		onLoad(opt) {
			if(opt.tab)
			{
				this.tab = opt.tab;
			}
			else
			{
				this.tab = -1;
			}
		},
		onShow() {
			this.addEvent();
		},
		onReady() {
			this.$refs.purchBillListBox.initData(this.tab);
		},
				
		methods: {
			/********/
			addEvent()
			{
				uni.$on(eventCtrl.COPY_RETURN_EDIT_EVENT,this.actHandler);
			},
			
			actHandler(id)
			{
				this.curPage = id;
				this.$refs.changeTab.actHandler1(id);
			},
			
			/***第三页单据应该展示的数据为**/
			setBillsThree(res)
			{
				this.$refs.purchBillsInfo.createdOrderInfo(res);
			},
			
			/***添加新的客户***/
			addNewCustom()
			{
				supplierCtrl.addSupplier = 1;
				this.$refs.changeTab.addNewCustom();
			},
			
			/****修改云单价格，更新单据列表***/
			changeYunBillPrice(data)
			{
				this.$refs.purchBillListBox.changeYunBillPrice(data);
			},
		},
	}
</script>
<style lang="scss">
	.content
	{
		display: flex;
		justify-content: flex-start;
		min-width: 820px;
		height: 100%;
		position: relative;
	}
	
</style>